package handler

import (
	"Gin/api/request"
	"Gin/global/model"
	"Serve/VideoSrv"
	"context"
	"github.com/gin-gonic/gin"
	"net/http"
)

func VideoAudit(c *gin.Context) {
	var VideoAuditRequest request.VideoAuditRequest
	if err := c.ShouldBind(&VideoAuditRequest); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code":    http.StatusBadRequest,
			"message": err.Error(),
		})
		return
	}
	audit, err := model.VideoClient.Audit(context.Background(), &VideoSrv.AuditRequest{
		UserId:      int64(VideoAuditRequest.UserId),
		VideoId:     int64(VideoAuditRequest.VideoId),
		AuditStatus: int64(VideoAuditRequest.AuditStatus),
	})
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code":    http.StatusBadRequest,
			"message": err.Error(),
		})
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"code":    http.StatusOK,
		"message": "success",
		"data":    audit,
	})
}
